<?php
    namespace Admin\Controller;
    use Think\Controller;
    function checkLogin()
    {
        if(!isset($_SESSION['aid']))
        {
            if(isset($_SESSION['author_id'])){
                return true;
            }
            
//            redirect('登入超时或未登入，请重新登入','__APP__/Admin/Login/login');
            // header('location:./index.php/Admin/Index/login');
            // success('请登录管理员账号','.//Admin/Login/login');
//            redirect('index1');
//             redirect('Login/login');
            
           baoAlert('登入超时或未登入，请重新登入',U('Admin/Login/login'));
        }
    }
    
    function checkadmin()
    {
        $ad = M('admin');
        $admin = $ad->where(array('id' => $_SESSION['aid']))->find();
        return $admin;
    }
    
    function baoAlert($message, $url = '') {
        $str = '<script>';
        $str.='parent.alert("' . $message . '");';
        if (!empty($url)) {
            $str.='parent.location.href="' . $url . '";';
}
        $str.='</script>';
        exit($str);
    }
    